package entity;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Objects;

/**
 * 购物车实体类
 */
public class ItemCart implements Serializable {
    // 序列化版本号
    private static final long serialVersionUID = 1L;
    // 购物车id
    private int id;
    // 用户id
    private int userId;
    // 商品id
    private int itemId;
    // 商品数量
    private int num;
    // 商品状态，1-正常，0-删除
    private boolean status = true;
    // 创建时间
    private java.sql.Timestamp created;
    // 修改时间
    private java.sql.Timestamp updated;

    public ItemCart() {
    }

    public ItemCart(int id, int userId, int itemId, int num, boolean status, Timestamp created, Timestamp updated) {
        this.id = id;
        this.userId = userId;
        this.itemId = itemId;
        this.num = num;
        this.status = status;
        this.created = created;
        this.updated = updated;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public int getItemId() {
        return itemId;
    }

    public void setItemId(int itemId) {
        this.itemId = itemId;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public boolean getStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }

    public Timestamp getCreated() {
        return created;
    }

    public void setCreated(Timestamp created) {
        this.created = created;
    }

    public Timestamp getUpdated() {
        return updated;
    }

    public void setUpdated(Timestamp updated) {
        this.updated = updated;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ItemCart itemCart = (ItemCart) o;
        return id == itemCart.id && userId == itemCart.userId && itemId == itemCart.itemId && num == itemCart.num && status == itemCart.status && Objects.equals(created, itemCart.created) && Objects.equals(updated, itemCart.updated);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, userId, itemId, num, status, created, updated);
    }

    @Override
    public String toString() {
        return "ItemCart{" +
                "id=" + id +
                ", userId=" + userId +
                ", itemId=" + itemId +
                ", num=" + num +
                ", status=" + status +
                ", created=" + created +
                ", updated=" + updated +
                '}';
    }
}
